//
//  HandsVC.m
//  YuDou
//
//  Created by yingqi on 2018/6/22.
//  Copyright © 2018年 yingqi. All rights reserved.
//

#import "HandsVC.h"
#import "HandsVM.h"
#import "MenuView.h"
@interface HandsVC ()
@property (nonatomic ,strong) MenuView *menuView;

@end

@implementation HandsVC

- (void)viewDidLoad {
    [super viewDidLoad];
        
}

- (MenuView *)menuView
{
    if (!_menuView) {
        _menuView = [MenuView menuView];
        _menuView.frame = CGRectMake(0, -kMenuViewH, kScreenWidth,kMenuViewH);
    }
    return _menuView;
}


- (void)setupUI
{
    [super setupUI];
    [self.collectionView addSubview:self.menuView];
    self.collectionView.contentInset = UIEdgeInsetsMake(kMenuViewH, 0, 0,  0);//设置内边距
    
}

- (void)loadData
{
    __weak typeof(self) weak_self = self;
    
    dispatch_group_t group = dispatch_group_create();
    
    dispatch_group_enter(group);
    [HandsVM getAnchorGroups:^(id anchorGroups) {
        
        [weak_self handelAnchorGroupsData:anchorGroups];

        dispatch_group_leave(group);
    }];
}

- (void)handelAnchorGroupsData:(NSArray *)returnValue
{
    self.menuView.groups = returnValue;
    [self.anchorGroups addObjectsFromArray:returnValue];
    [self.collectionView reloadData];
    [self loadDataFinished];
}

@end
